import router from '@system.router';
import prompt from '@system.prompt';
import device from '@system.device';
export default {
    props: [
            'listData',
        'descData',
        'urlData',

    ],
    data() {
       return {
           desc:this.descData,
           url:this.urlData,
        list: this.listData,
           windowH:780,
       }
    },
    onInit(){
        console.log(this.list.length)
        device.getInfo({
            success:(data)=> {
                this.windowH=data.windowHeight-200
            }
        });
    },
    triggerCollapse(e, id) {

        if (!this.list[e].pages) {
            this.goDetailPage('', this.list[e].url);
            return;
        }
        for (var i = 0; i < this.list.length; ++i) {
            if (e === i) {
                this.list[i].open = !this.list[e].open;
            } else {
                this.list[i].open = false;
            }
        }
    },
    goDetailPage(panel, e) {
        if(!e){
            return  prompt.showToast({
                message: '接口或组件未开发完成',
                duration: 2000,
            });
        }
        let uri='';
        if (typeof e === 'string') {
            uri = `pages/${panel}/${e}-c/${e}-c`
        }else{
        // 处理二级封装的情况
            uri = `pages/${panel}/${e.page}/${e.page}`
        }
        router.push({
            uri:uri,
        })
    }
}
